necessary=c("adehabitat")

#check if library is installed

installed = necessary %in% installed.packages()

#if library is not installed, install it

if (length(necessary[!installed]) >=1) install.packages(necessary[!installed], dep = T)

#load the libraries

for (lib in necessary) library(lib,character.only=T)